﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using QLT_Public;
using QLT_BLL;
using QLThuoc_report;

namespace GiaoDien
{
    public partial class frm_TKeCTThuocNhap : DevExpress.XtraEditors.XtraForm
    {
        public frm_TKeCTThuocNhap()
        {
            InitializeComponent();
        }
        private string _tenLoaiThuoc;

        public string TenLoaiThuoc
        {
            get { return _tenLoaiThuoc; }
            set { _tenLoaiThuoc = value; }
        }
        ThongKe_BLL thongke_bll = new ThongKe_BLL();
        public void GetData()
        {
            cmbTenLoaiThuoc.Text = TenLoaiThuoc;
        }
        private void frm_TKeCTThuocNhap_Load(object sender, EventArgs e)
        {
            GetData();
            LoaiThuoc_Public lt = new LoaiThuoc_Public();
            lt.TenLoaiThuoc = cmbTenLoaiThuoc.Text;
            gridControl1.DataSource = thongke_bll.ChiTiet_TkeThuocNhap(lt);
        }

        private void cmbTenLoaiThuoc_TextChanged(object sender, EventArgs e)
        {
            LoaiThuoc_Public lt = new LoaiThuoc_Public();
            lt.TenLoaiThuoc = cmbTenLoaiThuoc.Text;
            gridControl1.DataSource = thongke_bll.ChiTiet_ThongKe_LoaiThuoc(lt);
            //try
            //  {
            string sql = "select * from tbl_LoaiThuoc where TenLoaiThuoc like N'" + cmbTenLoaiThuoc.Text + "'";
            DataTable dt = new DataTable();
            dt = thongke_bll.TaoBang(sql);
            cob_MaLoaiThuoc.DataSource = dt;
            cob_MaLoaiThuoc.DisplayMember = "MaLoaiThuoc";
            //    }

            //catch(Exception)

            //{ }
        }

        private void cmbTenLoaiThuoc_MouseClick(object sender, MouseEventArgs e)
        {
            DataTable dt = new DataTable();
            string sql = "select * from tbl_LoaiThuoc";
            dt = thongke_bll.TaoBang(sql);
            cmbTenLoaiThuoc.DataSource = dt;
            cmbTenLoaiThuoc.DisplayMember = "TenLoaiThuoc";
            cob_MaLoaiThuoc.DataSource = dt;
            cob_MaLoaiThuoc.DisplayMember = "MaLoaiThuoc";
        }
        private void bbi_In_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
           // Frm_TKeCTThuocNhapVe f = new Frm_TKeCTThuocNhapVe();
            //f.TenLoaiThuoc = int.Parse(cob_MaLoaiThuoc.Text);
           // f.ShowDialog();
        }

        private void bbi_Thoat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            this.Close();
        }
    }
}